# -*- encoding: utf-8 -*-


weight = [2, 2, 4, 6, 3]
w = 9
max_weigh_list = [0]


def f(i, cw):
    if cw > w or i == len(weight):
        if cw > max(max_weigh_list):
            max_weigh_list.append(cw)
        return
    f(i + 1, cw)
    if cw + weight[i] <= w:
        f(i + 1, cw + weight[i])


f(0, 0)
print(max_weigh_list)
